package com.yanqu.road.server.cmd.activity.operamask;

import com.yanqu.road.entity.activity.operamask.OperaMaskSceneRank;
import com.yanqu.road.entity.player.UserBaseInfo;
import com.yanqu.road.logic.pb.OperaMaskPb2;
import com.yanqu.road.logic.pb.PlayerBasePb;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.OperaMaskProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.activity.operamask.CrossOperaMaskMgr;
import com.yanqu.road.server.manager.user.CrossUserMgr;
import com.yanqu.road.server.protocol.CrossProtocol;

@Cmd(code = CrossProtocol.C2_OPERA_MASK_UPDATE_SCENE_RANK, desc = "")
public class CrossOperaMaskUpdateSceneRankCmd extends CrossCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {

        OperaMaskProto.CrossOperaMaskUpdateSceneRankReqMsg reqMsg = OperaMaskProto.CrossOperaMaskUpdateSceneRankReqMsg.parseFrom(packet.getBytes());
        int activityId = reqMsg.getActivityId();
        int sceneId = reqMsg.getSceneId();
        OperaMaskProto.OperaMaskGetSceneRankTemp rankMsg = reqMsg.getRankMsg();

        OperaMaskSceneRank rank = OperaMaskPb2.parseOperaMaskSceneRank(activityId, sceneId, rankMsg);
        CrossOperaMaskMgr.rankChange(rank);

        UserBaseInfo userBaseInfo = PlayerBasePb.parseToUserBaseInfo(rankMsg.getPlayerBaseData());
        CrossUserMgr.updateUserBaseInfo(rank.getUserId(), userBaseInfo);

    }

    @Override
    public void sendData() {

    }
}
